import vue from "@vitejs/plugin-vue";
import { PluginOption } from "vite";
import VueJsx from "@vitejs/plugin-vue-jsx";
import autoImport from "./autoImport";
import autoComponen from "./autoComponents";
import autoStyleImport from "./autoStyleImport";
import autoSvgIcons from "./autoSvgIcons";
import { ViteEjsPlugin } from "vite-plugin-ejs";
import setupExtend from "vite-plugin-vue-setup-extend";
import versionUpDate from "./versionUpDate";

export default function createVitePlugins(viteEnv: Record<string, string>, isBuild: boolean = false, CurrentTimeVersion) {
  const vitePlugins: PluginOption[] = [vue(), VueJsx()];
  // 按需引入常用插件，如vue,vue-router
  vitePlugins.push(autoImport());
  // 按需引入组件
  vitePlugins.push(autoComponen());
  // 按需引入vant 弹框等样式
  vitePlugins.push(autoStyleImport());
  // 按需导入icon
  vitePlugins.push(autoSvgIcons());
  // vue setup属性扩展
  vitePlugins.push(setupExtend());
  // 配置htlm模板
  vitePlugins.push(
    ViteEjsPlugin({
      title: viteEnv.VITE_APP_TITLE
    })
  );
  // 打包版本生成插件
  // vitePlugins.push(versionUpDate({ version: CurrentTimeVersion }));

  return vitePlugins;
}
